<template>
  <div class="ReceivedOrAcceptedResume">
    <template v-if="globalUserInfo.roleId == '0'">
      <div>
        <el-container>
          <el-main>
            <div class="title">投递的简历</div>
            <hr/>
            <el-table :data="page.rows" style="width: 100%" v-loading="loading">
              <el-table-column prop="postJobName" label="职位名称"></el-table-column>
              <el-table-column prop="comName" label="公司名称"></el-table-column>
              <el-table-column prop="postTime" label="投递时间"></el-table-column>
            </el-table>
            <div class="block" style="margin-top: 20px; text-align: center;">
              <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next" :total="page.total"></el-pagination>
            </div>
          </el-main>
        </el-container>
      </div>
    </template>
    <template v-if="globalUserInfo.roleId == '1'">
      <div>
        <el-container>
          <el-main>
            <div class="title">收到的简历</div>
            <hr/>
            <el-table :data="page.rows" style="width: 100%" v-loading="loading">
              <el-table-column prop="postJobName" label="职位名称" width="120"></el-table-column>
              <el-table-column prop="name" label="投递人姓名" width="100"></el-table-column>
              <el-table-column prop="age" label="年龄"></el-table-column>
              <el-table-column prop="gender" label="性别"></el-table-column>
              <el-table-column prop="education" label="学历"></el-table-column>
              <el-table-column prop="specialty" label="专业"></el-table-column>
              <el-table-column prop="arrivalTime" label="到岗时间" width="100"></el-table-column>
              <el-table-column prop="mobile" label="手机号" width="120"></el-table-column>
              <el-table-column prop="jobNature" label="工作性质"></el-table-column>
              <el-table-column prop="experience" label="工作经验"></el-table-column>
              <el-table-column prop="experience" label="工作经历"></el-table-column>
              <el-table-column prop="postTime" label="投递时间" fixed="right" width="200"></el-table-column>
            </el-table>
            <div class="block" style="margin-top: 20px; text-align: center;">
              <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next" :total="page.total"></el-pagination>
            </div>
          </el-main>
        </el-container>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  mounted(){
    this.init();
  },
  methods:{
    async init(page=this.page){
      this.loading = true;
      if(this.globalUserInfo.roleId == '0'){
        let res = await this.$store.dispatch('handlelistForUser',{
          pageNumber: page,
          pageSize: this.number,
          userId: this.globalUserInfo.userId,
        });
        console.log(res)
        this.page = res.page;
      }else if(this.globalUserInfo.roleId == '1'){
         let res = await this.$store.dispatch('handlelistForCompany',{
          pageNumber: page,
          pageSize: this.number,
          comId: this.globalUserInfo.company.comId,
        });
        console.log(res)
        this.page = res.page;
      }

      setTimeout(()=>{
        this.loading = false;
      },500)
    },

    handleCurrentChange(page){
      this.page = page;
      this.init();
    }
  },
  data() {
    return {
      number: 10,
      page: 1,
      tableData: [],
      loading: false
    };
  },
  computed: {
    globalUserInfo() {
      return this.$store.state.home.globalUserInfo;
    }
  }
};
</script>

<style lang='less'>
.ReceivedOrAcceptedResume {
  .title { font-size: 20px; line-height: 2; }
}
</style>
